package org.jeecg.entity.car;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.util.StringUtils;
import org.jeecg.enums.*;
import org.jeecg.enums.car.CarOrderTypeEnum;
import org.jeecg.enums.car.CarSyncStatusEnum;
import org.jeecg.enums.car.CheckStatusEnum;
import org.jeecg.modules.system.entity.BaseEntity;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @Description: 车禁订单
 * @Author: liurui
 * @Date:   2020-09-16
 * @Version: V1.0
 */
@Data
@TableName("car_order")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="car_order对象", description="车禁订单")
public class CarOrder  extends BaseEntity {
    
	/**id*/
	@TableId(type = IdType.ID_WORKER_STR)
    @ApiModelProperty(value = "id")
	private String id;
	/**tenantId*/
    @ApiModelProperty(value = "tenantId")
	private String tenantId;

    private String projectId;

    @TableField(exist = false)
    private String projectName;

    private String parkId;

	/**用户id*/
    @ApiModelProperty(value = "用户id")
	private String userId;

    @ApiModelProperty(value = "优惠券id")
    private String derateId;

    @ApiModelProperty(value = "优惠券明细id")
    private String derateDetailId;

	@Excel(name = "银行渠道", width = 15)
	@ApiModelProperty(value = "银行渠道")
	private String payChannel;

	/**支付人注册手机号*/
    @ApiModelProperty(value = "手机号")
	private String userMobile;

	@Excel(name = "手机号", width = 15)
	@TableField(exist = false)
    private String userMobileStr;

	/**车辆id*/
    @ApiModelProperty(value = "车辆id")
	private String carId;
	/**车牌号*/
	@Excel(name = "车牌号", width = 15)
    @ApiModelProperty(value = "车牌号")
	private String carNo;
	/**车位id*/
	@Excel(name = "车位id", width = 15)
    @ApiModelProperty(value = "车位id")
	private String carPortId;
	/**车位号码*/
	@Excel(name = "车位号码", width = 15)
    @ApiModelProperty(value = "车位号码")
	private String carPortNum;
	/**订单类型 0:临停 1:月卡*/
    @ApiModelProperty(value = "订单类型 0:临停 1:月卡")
	@Dict(dicCode = "order_type")
	private Integer orderType;

    /**续费类型 0 正常续费 1：断缴续费 2：未缴费*/
    @ApiModelProperty(value = "续费类型 0 正常续费 1：断缴续费  2：未缴费")
	@Dict(dicCode = "charge_type")
	private Integer chargeType;

	@TableField(exist = false)
	@Excel(name = "订单类型", width = 15)
	private String orderTypeStr;

	/**充值涵盖开始日期*/
	@Excel(name = "充值涵盖开始日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "充值涵盖开始日期")
	private Date coverStartTime;
	/**充值涵盖结束日期*/
	@Excel(name = "充值涵盖结束日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "充值涵盖结束日期")
	private Date coverEndTime;

	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@ApiModelProperty(value = "前次的缴费截止日期")
	private Date prevEndTime;

	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@ApiModelProperty(value = "前次的缴费开始日期")
	private Date prevStartTime;

	/**充值月数*/
	@Excel(name = "充值月数", width = 15)
    @ApiModelProperty(value = "充值月数")
	private Integer months;
	/**订单号(yyyyMMddHHmmss+P+4位流水号)*/
	@Excel(name = "订单号", width = 15)
    @ApiModelProperty(value = "订单号")
	private String sn;

	@Excel(name = "银行订单号", width = 15)
	@ApiModelProperty(value = "银行订单号")
	private String transNo;
	@ApiModelProperty(value = "车禁云平台订单号-通知开闸放行必要参数")
	private String orderNo;
	@ApiModelProperty("进出记录id")
	private String recordId;

	/**支付模式 alipay:支付宝,weixinpay:微信,offline:线下*/
	@Excel(name = "支付模式", width = 15, dicCode = "pay_mode")
    @ApiModelProperty(value = "支付模式: alipay:支付宝,weixinpay:微信,offline:线下")
	@Dict(dicCode = "pay_mode")
	private String payMode;

	/**支付方式*/
    @ApiModelProperty(value = "支付方式")
	private String payType;

	/**支付方式*/
	@Excel(name = "支付方式", width = 15)
    @ApiModelProperty(value = "支付方式")
	@TableField(exist = false)
	private String payTypeStr;

	/**应收金额*/
	@Excel(name = "应收金额", width = 15)
    @ApiModelProperty(value = "应收金额")
	private java.math.BigDecimal payDue;
	/**优惠金额*/
	@Excel(name = "优惠金额", width = 15)
    @ApiModelProperty(value = "优惠金额")
	private java.math.BigDecimal payReduced;
	/**支付金额(单位:元)*/
	@Excel(name = "支付金额(元)", width = 15)
    @ApiModelProperty(value = "支付金额(元)")
	private java.math.BigDecimal payAmount;
	/**费用说明*/
    @ApiModelProperty(value = "费用说明")
	private String payMemo;
	/**支付时间*/
	@Excel(name = "支付时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "支付时间")
	private Date payTime;
	/**支付状态*/
    @ApiModelProperty(value = "支付状态:0 未支付 2 支付中 1支付成功")
	private Integer payStatus;

	@TableField(exist = false)
	@Excel(name = "支付状态", width = 15)
	private String payStatusStr;

	/**参数化请求内容*/
    @ApiModelProperty(value = "参数化请求内容")
	private String request;
	/**支付接口响应内容*/
    @ApiModelProperty(value = "支付接口响应内容")
	private String response;

	/**订单审核状态*/
    @ApiModelProperty(value = "订单审核状态")
	private Integer checkStatus;

	@TableField(exist = false)
	private  String checkStatusStr;

	/**同步状态(0:未同步  1:已同步)*/
    @ApiModelProperty(value = "同步状态(0:未同步  1:已同步)")
	private Integer syncStatus;
	@ApiModelProperty(value = "发票类型 (0:个人,1:企业)")
	private Integer invoiceType;
	@ApiModelProperty(value = "发票代码 簿")
	private String invoiceDm;
	@ApiModelProperty(value = "发票号码 号")
	private String invoiceHm;
	/**开票账号*/
	@Excel(name = "开票账号", width = 15)
	@ApiModelProperty(value = "开票账号")
	private String invoiceAccount;
	/**开票地址*/
	@Excel(name = "开票地址", width = 15)
	@ApiModelProperty(value = "开票地址")
	private String invoiceAddress;
	/**开票税号*/
	@Excel(name = "开票税号", width = 15)
	@ApiModelProperty(value = "开票税号")
	private String invoiceEin;
	/**开票邮箱*/
	@Excel(name = "开票邮箱", width = 15)
	@ApiModelProperty(value = "开票邮箱")
	private String invoiceEmail;
	/**开票人*/
	@Excel(name = "开票人", width = 15)
	@ApiModelProperty(value = "开票人")
	private String invoiceName;
	/**开票状态*/
	@Excel(name = "开票状态", width = 15)
	@ApiModelProperty(value = "开票状态（1：不开票  2：线下票据  3：电子发票）")
	private Integer invoiceStatus;

	/**退款状态0:未退款 1:已退款*/
	@ApiModelProperty(value = "退款状态0:未退款 1:已退款")
	@Dict(dicCode = "refund_status")
	private Integer refundStatus;
	/**退款者*/
	@ApiModelProperty(value = "退款者")
	private String refundBy;
	/**退款日期*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@ApiModelProperty(value = "退款日期")
	private Date refundDate;


	/**记录创建时间*/
//	@Excel(name = "记录创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "记录创建时间")
	private Date createTime;
	/**记录修改时间*/
//	@Excel(name = "记录修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "记录修改时间")
	private Date updateTime;
	/**createBy*/
    @ApiModelProperty(value = "createBy")
	private String createBy;
	/**updateBy*/
    @ApiModelProperty(value = "updateBy")
	private String updateBy;
	/**delFlag*/
    @ApiModelProperty(value = "delFlag")
	private String delFlag;
	/**备注*/
	@Excel(name = "备注", width = 15)
    @ApiModelProperty(value = "备注")
	private String remarks;

	private String carTypeName;

	@TableField(exist = false)
	private  String  feeStartDate;

	//付款人
	@TableField(exist = false)
	private  String payer;

	//退款人
	@TableField(exist = false)
	private String refundName;

	@TableField(exist = false)
	private String createName;

	//搜索条件 开始时间
	@TableField(exist = false)
	private String searchStartTime;
	//搜索条件 结束时间
	@TableField(exist = false)
	private String searchEndTime;
	@TableField(exist = false)
	private String payQRCode;
	@TableField(exist = false)
	private String feeItemId;
	/** 发票代码*/
	@TableField(exist = false)
	private String fphm;


	public String getUserMobileStr() {
		if (StringUtils.isBlank(userMobile) || "null".equals(userMobile)){
			return "无";
		}
		return userMobile;
	}

	public String getOrderTypeStr() {
		return CarOrderTypeEnum.getDesc(this.getOrderType());
	}

	public String getPayStatusStr() {
		return PayStatusEnum.getDesc(this.getPayStatus());
	}

	public String getSyncStatusStr() {
		return CarSyncStatusEnum.getDesc(this.getSyncStatus());
	}

	public String getCheckStatusStr() {
		return CheckStatusEnum.getDesc(this.getCheckStatus());
	}
}
